#include "src/analysis/Analysis.h"
#include <iostream>
#include <fstream>
#include <string>

// 函数声明
std::string readFileToString(const std::string& filePath);

int main(int argc, char* argv[]) {
    if (argc < 2) {
        std::cerr << "Usage: " << argv[0] << " <file_path>" << std::endl;
        return 1;
    }

    std::string filePath = argv[1]; // 从命令行参数获取文件路径
    std::string command = readFileToString(filePath);

    if (!command.empty()) {
        Analysis::Analysis_Command(command);
    } else {
        std::cerr << "No command found in the file." << std::endl;
    }

    return 0;
}

// 函数定义
std::string readFileToString(const std::string& filePath) {
    std::ifstream file(filePath);
    if (!file.is_open()) {
        std::cerr << "Failed to open file: " << filePath << std::endl;
        return "";
    }

    std::string content((std::istreambuf_iterator<char>(file)), std::istreambuf_iterator<char>());
    file.close();
    return content;
}
